<?php


require '\vendor\johnlui\aliyun-oss\AliyunOSS.php';

class Oss{

	private $ossClient;

	public function __construct(){
	    $this->ossClient = AliyunOSS::boot(
	    	'http://oss-cn-qingdao.aliyuncs.com',
	    	'TneKZ4tMAOt0GGLS',
	    	'RQOICq5po9abw4r9nwt84wmUZmHwPE');
	}

	public static function upload($ossKey, $filePath)
	{
	    $oss = new OSS();
	    $oss->ossClient->setBucket('qdb');
	    $oss->ossClient->uploadFile($ossKey, $filePath);
	}


	public static function getUrl($ossKey)
	{
	    $oss = new OSS();
	    $oss->ossClient->setBucket('yishuodian-test');
	    return $oss->ossClient->getUrl($ossKey, new \DateTime("+1 day"));
	}

	public static function createBucket($bucketName)
	{
	    $oss = new OSS();
	    return $oss->ossClient->createBucket($bucketName);
	}

	public static function getAllObjectKey($bucketName)
	{
	    $oss = new OSS();
	    return $oss->ossClient->getAllObjectKey($bucketName);
	}

}